package com.sparrow.mvc.ui;

@SuppressWarnings("serial")
public class JRadioBox extends JWebInputControl {
	private String checked;

	@Override
	public String setTagNameAndGetTagAttributes() {
		super.setType("radio");
		Object isChecked = this.pageContext.getRequest().getAttribute(
				this.getId() + ".checked");
		if (isChecked != null && isChecked.toString().trim() != "false") {
			return " checked=\"checked\" ";
		} else {
			String paraValue = this.pageContext.getRequest().getParameter(
					this.getCtrlName());
			if (paraValue != null
					&& this.getValue().equals(
							String.format(" value=\"%1$s\"", paraValue
									.toString().replace("\"", "\\")))) {
				return " checked=\"checked\" ";
			} else if (this.getChecked() != null
					&& this.getChecked().trim() != "false") {
				return " checked=\"checked\" ";
			} else {
				return "";
			}
		}
	}

	public String getChecked() {
		return checked;
	}

	public void setChecked(String checked) {
		this.checked = checked;

	}
}
